package com.park.gateway.config;

import com.park.gateway.filters.IpWhiteListGatewayFilterFactory;
import com.park.gateway.mapper.IpWhiteListMapper;
import com.park.gateway.utils.RedisUtils;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.factory.AddRequestParameterGatewayFilterFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName FilterConfig
 * @Description 过滤
 * @Date 2023/6/9 16:46
 * @Author huxiaohua
 */
@Configuration
public class FilterConfig {
    @Autowired
    private IpWhiteListMapper ipWhiteListMapper;
    @Autowired
    private RedisUtils redisUtils;
    @Autowired
    private RedissonClient redissonClient;

    /**
     * ip白名单校验filter
     * @return
     */
    @Bean
    public IpWhiteListGatewayFilterFactory ipWhiteListGatewayFilterFactory() {
        return new IpWhiteListGatewayFilterFactory(ipWhiteListMapper, redisUtils, redissonClient);
    }
}
